package com.loong.data.handler;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.math.BigDecimal;

/**
 * @Description:
 * @Author: hzp
 * @Date: 2020-12-20 21:28
 */
@Service("deliveryPriceCalculator")
public class DeliveryPriceCalculatorStrategy implements CalculatorStrategy{
    @Override
    public BigDecimal calculate(BigDecimal basePrice, BigDecimal distance) {
        if(ObjectUtils.isEmpty(basePrice)){
            basePrice = new BigDecimal(0);
        }
        return basePrice.multiply(distance).setScale(0,BigDecimal.ROUND_UP);
    }
}
